<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script src="./node_modules/axios/dist/axios.js"></script>
  <script>
    axios({
      method: 'POST', // GraphQL 的请求方法必须是 POST
      url: 'http://localhost:4000/graphql',
      data: {
        query: `
          query getUser($id: ID!) {
            user(id: $id) {
              id
              name
            }
          }
        `,
        variables: {
          id: 2
        }
      }
    }).then(res => {
      console.log(res.data)
    })

    // 获取单个文章
    const id = 1
    axios({
      method: 'POST', // GraphQL 的请求方法必须是 POST
      url: 'http://localhost:4000/graphql',
      data: {
        query: `
          query getUser {
            user(id: ${id}) {
              id
              name
            }
          }
        `
      }
    }).then(res => {
      console.log(res.data)
    })

  </script>
</body>
</html>
